package org.meandslava.calc.arithmetic;

import java.text.DecimalFormat;
import java.util.Deque;
import java.util.LinkedList;

import android.text.Editable;

public abstract class Term {
	public static final String CATEGORY_UNARY = "unary";
	public static final String CATEGORY_BINARY = "binary";
	public static final String CATEGORY_FIXED_NUMBER = "num";
	public static final String CATEGORY_EXPRESSION = "expression";
	
	protected static DecimalFormat format = new DecimalFormat("###############.###############");
	public abstract double calc(double previousValue, LinkedList<Term> queue);
	public abstract boolean back();
	public abstract void write(Editable editable);
	
	public boolean process(String categoryTagAndAction){
		String[] catAndTag = categoryTagAndAction.split(":");
		if(catAndTag.length == 2){
			return process(catAndTag[0], catAndTag[1]);
		}
		throw new IllegalArgumentException();
	}
	public abstract boolean process(String categoryTag, String action);
}
